/**
 * @author janet
 * @date 2015-5-4
 */
package net.oscorner.services.menu;

import java.sql.SQLException;
import java.util.List;

import net.oscorner.dao.commons.CommonDao;
import net.oscorner.dao.menu.MenuDao;
import net.oscorner.entiry.Menus;


/**
 * @author janet
 * @date 2015-5-4 下午4:12:16
 * 
 */

public class MenuServiceImpl implements MenuService{

	private CommonDao commonDao ;
	private MenuDao menuDao;
	
	public MenuDao getMenuDao() {
		return menuDao;
	}

	public void setMenuDao(MenuDao menuDao) {
		this.menuDao = menuDao;
	}

	public CommonDao getCommonDao() {
		return commonDao;
	}

	public void setCommonDao(CommonDao commonDao) {
		this.commonDao = commonDao;
	}

	@Override
	public boolean addMenus(Menus entity) {
		// TODO Auto-generated method stub
		commonDao.createNewEntity(entity);
		return true;
	}

	@Override
	public boolean editMenus(Menus entity) {
		// TODO Auto-generated method stub
		commonDao.updateEntity(entity);
		return true;
	}

	@Override
	public boolean deleteMenus(Menus entity) {
		// TODO Auto-generated method stub
		commonDao.deleteEntity(entity);
		return true;
	}

	@Override
	public List<Menus> queryMenus(Menus entity) {
		// TODO Auto-generated method stub
		List<Menus> list = null;;
		try {
			list = menuDao.queryMenuList(entity);
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
			return null;
		}
		return list;
	}

	@Override
	public int queryListCount(Menus entity) {
		// TODO Auto-generated method stub
		int result = 0;
		try {
			result = menuDao.queryListCount(entity);
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return result;
	}

	@Override
	public Menus getMenu(String menuId) {
		// TODO Auto-generated method stub
		Menus m = new Menus();
		m.setMenuId(menuId);
		try {
			return menuDao.getMenu(m);
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
			return null;
		}
	}

}
